//****************************************************
// Porman Project 2
// Filename: CAssert.h
// Date: 2008/02/28
// Author: KengYu Lin
// Modify:
//****************************************************
#ifndef _CASSERT_H
#define _CASSERT_H
#include "CGLDef.h"
#include "CLogger.h"

namespace Porman
{

namespace GL
{

#define GL_ASSERT(exp) \
exp; \
{ \
    GLenum error = glGetError(); \
    if( error != GL_NO_ERROR ){ \
        std::string sMsg = std::string(#exp) + std::string( gluErrorString(error) ); \
        LOG_ERROR( sMsg ); \
    } \
}

#define CG_ASSERT(exp) \
exp; \
{ \
    CGerror error = cgGetError(); \
    if( error != CG_NO_ERROR ){ \
        std::string sMsg = std::string(#exp) + std::string( cgGetErrorString(error) ); \
        LOG_ERROR( sMsg ); \
    } \
}

#define CGC_ASSERT(exp, cont) \
exp; \
{ \
    CGerror error = cgGetError(); \
    if( error == CG_COMPILER_ERROR ){ \
        std::string sMsg = std::string(#exp) + std::string( cgGetLastListing(cont) ); \
        LOG_ERROR( sMsg ); \
    }else if( error != CG_NO_ERROR ) { \
        std::string sMsg = std::string(#exp) + std::string( cgGetErrorString(error) ); \
        LOG_ERROR( sMsg ); \
    } \
}

}//End namespace GL

}//End nsmespace Porman

#endif